import type { Component } from 'vue';

type ComponentType =
  | 'Input'
  | 'InputTag'
  | 'Select'
  | 'RadioGroup'
  | 'Checkbox'
  | 'Divider'
  | 'InputNumber'
  | 'Autocomplete'
  | 'Radio'
  | 'RadioButtonGroup'
  | 'Switch'
  | 'TimePicker'
  | 'TimeSelect'
  | 'Slider'
  | 'SelectV2'
  | 'Tree'
  | 'TreeV2'
  | 'TreeSelect'
  | 'DatePicker'
  | 'UploadImage'
  | 'Rate'
  | 'ApiSelectV2'
  | 'ApiTreeSelect'
  | 'Cascader'
  | 'ApiCascader'
  | 'CascaderPanel'
  | 'InputNumberGroup'
  | 'WangEditor'
  | 'UploadAudio';

import {
  ElInput,
  ElInputTag,
  ElRadio,
  ElCheckbox,
  ElCascader,
  ElDatePicker,
  ElInputNumber,
  ElSwitch,
  ElTimePicker,
  ElTreeSelect,
  ElSlider,
  ElRate,
  ElDivider,
  ElAutocomplete,
  ElTimeSelect,
  ElSelectV2,
  ElTree,
  ElTreeV2,
  ElCascaderPanel,
} from 'element-plus';
import RadioGroup from './components/RadioGroup.vue';
import RadioButtonGroup from './components/RadioButtonGroup.vue';
import Select from './components/Select.vue';
import UploadImage from './components/UploadImage.vue';
import ApiSelectV2 from './components/ApiSelectV2.vue';
import ApiTreeSelect from './components/ApiTreeSelect.vue';
import InputNumberGroup from './components/InputNumberGroup.vue';
import WangEditor from './components/WangEditor.vue';
import ApiCascader from './components/ApiCascader.vue';
import UploadAudio from './components/UploadAudio.vue';

const componentMap = new Map<ComponentType, Component>();

componentMap.set('Input', ElInput);
componentMap.set('InputTag', ElInputTag);
componentMap.set('Checkbox', ElCheckbox);
componentMap.set('InputNumber', ElInputNumber);
componentMap.set('Autocomplete', ElAutocomplete);
componentMap.set('Radio', ElRadio);
componentMap.set('RadioGroup', RadioGroup);
componentMap.set('RadioButtonGroup', RadioButtonGroup);
componentMap.set('Divider', ElDivider);
componentMap.set('Switch', ElSwitch);
componentMap.set('TimePicker', ElTimePicker);
componentMap.set('DatePicker', ElDatePicker);
componentMap.set('TimeSelect', ElTimeSelect);
componentMap.set('Slider', ElSlider);
componentMap.set('Select', Select);
componentMap.set('SelectV2', ElSelectV2);
componentMap.set('Tree', ElTree);
componentMap.set('TreeV2', ElTreeV2);
componentMap.set('TreeSelect', ElTreeSelect);
componentMap.set('UploadImage', UploadImage);
componentMap.set('UploadAudio', UploadAudio);
componentMap.set('Rate', ElRate);
componentMap.set('ApiSelectV2', ApiSelectV2);
componentMap.set('ApiTreeSelect', ApiTreeSelect);
componentMap.set('Cascader', ElCascader);
componentMap.set('CascaderPanel', ElCascaderPanel);
componentMap.set('ApiCascader', ApiCascader);

componentMap.set('InputNumberGroup', InputNumberGroup);
componentMap.set('WangEditor', WangEditor);

function add(compName: ComponentType, component: Component) {
  componentMap.set(compName, component);
}

function del(compName: ComponentType) {
  componentMap.delete(compName);
}

export { componentMap, add, del };
export type { ComponentType };
